﻿/// <reference path="jquery-1.3.2-vsdoc.js" />
$(document).ready(function() {
    SetupStatements();
    SetupBills();
});

function SetupBills() {
    $("#bills .divLine")
        .draggable({ revert: 'invalid', helper: 'clone' })
        .each(function(index) {
            $(this).attr("id", index);
        })
        .mouseover(function() {
            $(this).addClass("selected");
        })
        .mouseout(function() {
            $(this).removeClass("selected");
        });
}

function SetupStatements() {
    $("#statements .divLine").droppable({
        over: function(event, ui) {
            $(this).addClass("selected");
        },
        out: function(event, ui) {
            $(this).removeClass("selected");
        },
        drop: function(event, ui) {
            PostbackNewAssociation(
                $(ui.draggable).children("[type=hidden]").val(),
                $(this).children("[type=hidden]").val());
        }
    });

    function PostbackNewAssociation(billId, statementId) {
        ShowBlock();
        $("#billId").val(billId);
        $("#statementId").val(statementId);
        $('form').submit();
    }
}